#!/bin/bash

sandboxdir=$(dirname $0)
. $sandboxdir/sb_vars.sh
. $sandboxdir/sb_common.sh

for D in $( find  $TUNGSTEN_SB -maxdepth 1 -type d -name "${SB_PREFIX}*"  )
do
    TUNGSTEN_BIN=$D/tungsten/tungsten-replicator/bin/
    mongodb_stop $D
    if [ -x $TUNGSTEN_BIN/replicator ]
    then
        $TUNGSTEN_BIN/replicator stop
        rm -rf $D
    fi
done

rm -rf $TUNGSTEN_SB/*

if [ -d $HOME/sandboxes/$SB_DIRECTORY ]
then
    sbtool -o delete -s $HOME/sandboxes/$SB_DIRECTORY
fi
